<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<%@include file="../../common/mastertop.jsp"%>
<p class="page-title">
	<i class="locale-icon"></i> <span>当前位置 : </span> <span
		class="cur-page-title">用户管理</span> <span>· 职位定义</span>
</p>

<form class="form-inline clearfix" id="seachform"
	action="${pageContext.request.contextPath}/set/job/index" method="post">
	<input type="hidden" name="catId" /> <input type="hidden"
		name="catLevel" />
	<div class="filter-warp rect-fff clearfix">
		<div class="form-group col-xs-6 col-lg-4">
			<span class="form-label">职位名称</span> <input type="text"
				class="form-control form-control-260" name="jobName"
				value="${model.jobName}">
		</div>

		<div class="form-group col-xs-6 col-lg-4">
			<span class="form-label">创建时间</span>
			<div class="datapicker-gloup">
				<div class="datapicker-box form-control-125 pull-left">
					<i class="runmi-icon datetimepicker-icon"></i> <input type="text"
						class="form-control" id="start-date" name="startTime" id="d17"
						value="${model.startTime}">
				</div>
				<span class="time-line pull-left">-</span>
				<div class="datapicker-box form-control-125 pull-left">
					<i class="runmi-icon datetimepicker-icon"></i> <input type="text"
						class="form-control" id="end-date" name="endTime" id="d18"
						value="${model.endTime}">
				</div>
			</div>
		</div>

		<div class="col-xs-12 text-center">
			<button type="button" class="btn runmi-primary buttonrole"
				onclick="edit('')" name="btnadd">新&nbsp;增</button>
			<button type="button" class="btn runmi-primary search-btn"
				onclick="seach()">查询</button>
		</div>
	</div>
	<div class="rect-fff table-warp">
		<div class="table-scroll">
			<table>
				<tr>
					<th width="110">操作</th>
					<th>职位ID</th>
					<th>职位名称</th>
					<th>创建人</th>
					<th>创建时间</th>
					<th>修改人</th>
					<th>修改时间</th>
				</tr>
				<c:forEach items="${model.items}" var="item" varStatus="itemStatus">
					<tr id="row_${item.id}">
						<td><span class="rm-table-btn buttonrole"
								  onclick="edit('${item.id}');" name="btnedit">修改</span> <span
								class="rm-table-btn buttonrole" onclick="del('${item.id}');"
								name="btndel">删除</span></td>
						<td>${item.id}</td>
						<td>${item.jobName}</td>
						<td>${item.createUserName}</td>
						<td><fmt:formatDate value="${item.createTime}" type="both"
											pattern="yyyy-MM-dd HH:mm:ss" /></td>
						<td>${item.updateUserName}</td>
						<td><fmt:formatDate value="${item.updateTime}" type="both"
											pattern="yyyy-MM-dd HH:mm:ss" /></td>

					</tr>
				</c:forEach>

			</table>
		</div>
		<vp:pages cpage="${model.cpage}" totalCount="${model.totalCount}"
			pageSize="${model.pageSize}" />

	</div>


</form>

<script type="text/javascript">
	function seach() {
		$("#cpage").val(1);
		oksubmit();
	}
	function oksubmit() {
		$("#btnOk").attr("disabled", "disabled");
		var objform = document.getElementById('seachform');
		objform.submit();
	}
	function del(id) {
		layer.confirm('确认要删除此职位吗', {
			title :'确认删除',
			btn : [ '确认', '取消' ]
		//按钮
		}, function() {
			sendOpTo(id);
		}, function() {

		});
	}
	function sendOpTo(id) {
		layer.load(1, {
			shade : [ 0.5, '#fff' ]
		});
		var postData = "jobId=" + id;
		$.ajax({
			type : "POST",
			url : "del",
			data : postData,
			contentType : "application/x-www-form-urlencoded;charset=UTF-8",
			async : true, // 同步  true 异步。默认是异步
			dataType : 'json',
			error : function(resultdata) {
				layer.closeAll();
			},
			success : function(resultdata) {
				layer.closeAll();
				if (resultdata.returnCode == "0000") {
					layer.alert('操作成功', {
						icon : 1
					}, function() {
						layer.closeAll();
						oksubmit();
					});
				} else {
					layer.alert(resultdata.returnMessage);
				}
			}
		});
	}

	function editReturn() {
		layer.closeAll();
		oksubmit();
	}
	function closeAll() {
		layer.closeAll();
	}
	function edit(id) {
		var domainUrl = "edit?jobId=" + id;
		layer.open({
			type : 2,
			title : '职位',
			area : [ '550px', '200px' ],
			content : domainUrl
		//iframe的url
		});
	}
</script>
<script>
    $('#start-date').datetimepicker({
        language:  'zh-CN',
        autoclose : true,
        minView : 2,
        format : 'yyyy/mm/dd',
        todayBtn:  1,
        pickerPosition:'bottom-left'//日期插件弹出的位置
    });
    $('#end-date').datetimepicker({
        language:  'zh-CN',
        autoclose : true,
        minView : 2,
        todayBtn:  1,
        format : 'yyyy/mm/dd',
        pickerPosition:'bottom-left'//日期插件弹出的位置
    });
</script>
<%@include file="../../common/masterbottom.jsp"%>